/**
 * 基本信息
 */
import React from 'react';
import { Form, Switch, Checkbox } from 'antd';
import { get as getPath } from 'object-path';

const formLayout = {
    wrapperCol: { span: 21 },
    labelCol: { span: 3 }
};

const More = ({ form, data }) => {
    const { outsideSignMustFlow, outsideSignMustPhoto, outsideSignMustRemark } = data;
    const getOutCardRule = () => {
        const wayList = [];
        if (outsideSignMustFlow) {
            wayList.push(1);
        }
        if (outsideSignMustRemark) {
            wayList.push(2);
        }
        if (outsideSignMustPhoto) {
            wayList.push(3);
        }
        return wayList;
    };
    return (
        <Form {...formLayout} style={{ minHeight: 200 }}>
            <Form.Item label="允许外勤打卡">
                {form.getFieldDecorator('allowOutsideSign', {
                    valuePropName: 'checked',
                    initialValue: getPath(data, 'allowOutsideSign', false)
                })(<Switch checkedChildren="开" unCheckedChildren="关" />)}
            </Form.Item>
            {form.getFieldValue('allowOutsideSign') && (
                <Form.Item label=" " colon={false}>
                    {form.getFieldDecorator('outCardRule', {
                        initialValue: getOutCardRule()
                    })(
                        <Checkbox.Group style={{ width: '100%' }}>
                            <div style={{ padding: '10px 0' }}>
                                <Checkbox value={1}>
                                    外勤打卡需审批，即员工需提交【外出】或者【出差】申请，审批通过后方可使用
                                </Checkbox>
                            </div>
                            <div style={{ padding: '10px 0' }}>
                                <Checkbox value={2}>外勤打卡需填写备注</Checkbox>
                            </div>
                            <div style={{ padding: '10px 0' }}>
                                <Checkbox value={3}>外勤打卡需拍照</Checkbox>
                            </div>
                        </Checkbox.Group>
                    )}
                </Form.Item>
            )}
        </Form>
    );
};

export default More;
